const app = getApp()
Page({
  data: {
  },
  handleSet: function (event) {
    var that = this;
    var openid = app.globalData.openid;
    var link = app.globalData.schlink;
    var user_id = app.globalData.bindInfo.user_id;
    var sign = app.globalData.bindInfo.sign;
    if (user_id == "" || user_id == null || user_id==undefined){
      wx.redirectTo({
        url: '../binding/binding'
      })
    }
    wx.showModal({
      title: '确定要解绑吗?',
      content: '',
      success: function (res) {
        if (res.confirm) {
          wx.request({
            url: getApp().globalData.baseUrl + 'unbindUserOauth',
            data: {
              link: link,
              openid: openid,
              user_id: user_id,
              sign: sign,
              oauth: "mapp"
            },
            method: "post",
            header: {},
            success: function (res) {
              if (res.data.code==200){
                if (res.data.data.code == 1) {
                  getApp().globalData.bindInfo = null;
                  getApp().globalData.accountInfo = null;
                  getApp().globalData.schlink = '';
                  getApp().globalData.isbind = false;
                  getApp().globalData.userInfo = null;
                  wx.redirectTo({
                    url: '../binding/binding'
                  })
                } else {
                  wx.showToast({
                    title: "已经解绑了",
                    icon: 'none',
                    duration: 1500
                  })
                  wx.redirectTo({
                    url: '../binding/binding'
                  })
                }
              }else{
                wx.showToast({
                  title: "解绑失败",
                  icon: 'none',
                  duration: 1500
                })
                wx.redirectTo({
                  url: '../center/center'
                })
              }
            }
          })
        }
      }
    })
  },
  onLoad: function (options) {
  },
  onReady: function () {
  },
  onShow: function () {
  },
  onHide: function () {
  },
  onUnload: function () {
  },
  onPullDownRefresh: function () {
  },
  onReachBottom: function () {
  },
  onShareAppMessage: function () {
  }
})